<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 1. 随机10个0-100的数 依次放到数组中

    var list = []; // len:0 1
    for (var i = 0; i < 10; i++) {
        var num = Math.round(Math.random() * 100);
        list[list.length] = num;
    }
    console.log(list);

    // 2. 计算10个数的和以及平均值(第一个基础上)  => 数组遍历

    var sum = 0;
    for (var i = 0; i < list.length; i++) {
        var item = list[i]; // 取出数组的每一项
        sum += item; 
    }
    console.log(sum);
    
    var avg = sum / list.length;
    console.log(avg);


    // 3. 将大于平均值的数提取出来 放到新数组中 => 数组遍历,取出每一个值和平均值比较
    var arr = [];
    for(var j = 0; j< list.length; j++){
        var item = list[j];
        if(item > avg){
            arr[arr.length] = item;
        }
    }
    console.log(arr);





</script>

</html>